A box on an object that promises its copies stay where they are put, so the game can answer collision questions about them from a look-up grid instead of checking every copy.
An object's editor (the Code tab) has a Never moves box. Tick it for an object whose copies are put somewhere and then stay there: walls, rocks, floor blocks, doors, pickups waiting to be collected, a bridge plank. It is a promise from you, and the game builds on it.
The promise is about each copy, once the game has started asking about it. A copy of that object will not:
x and y stay put, and nothing gives it a speed (hsp, vsp, speed, gravity) or moves it with move_slide, move_step, move_to and the other move_ calls;mask_w, mask_h, mask_x, mask_y and mask_sprite stay as they were, and so does its sprite, because an object that has no mask of its own takes its box from the picture (an object that gives both a mask width and a mask height can swap pictures freely, since the picture no longer decides the box);solid.Making more copies is fine, and so is destroying them. A wall can be built in the middle of the game and a crate can be smashed. The game notices and tidies its grid before the next question.
Asking the game "is anything of this object here?" normally means looking at every copy of it, one after another. A game with fifty walls and a dozen things asking about them every frame spends a lot of its frame on those looks. With the box ticked the game instead keeps a small grid of where the copies are, and a question looks at the few copies near the place it asks about. The answer is the same one the one-by-one check would have given, exactly: same boxes, same edges, same first match.
These are answered from the grid, for an object with the box ticked:
| Question | Name |
|---|---|
| could I stand here? | pos_free |
| would I touch any copy here? | pos_meeting |
| is this point inside a solid copy? | pos_solid |
| is this point inside any copy? | point_meeting |
| which copy is at this point? | collision_point |
| which copy is in this rectangle? | collision_rect |
| slide around it | move_slide_solid |
The cost of one question becomes about the same however many copies there are. Measured on a console build (the platformer template's floor, 17 ground blocks, twelve objects each asking four questions every frame), one question cost about 7,700 cycles checked one by one and about 1,200 with the box ticked, and the time the Step events took went from 135% of a frame (too slow: the game would drop to about 40 frames a second) to 24%. With a single asker, as in the shipped templates, the saving is small, around a third of a percent of a frame. The more copies and the more askers, the more it is worth.
Other questions are not touched by the box: collision_line and collision_circle still look at every copy, and so does the Collision event, which also has to tell you which copy it found. They give the same answers they always did. A grid costs a little memory (about 1.7 KB for a pool of 24 copies) and a little program size (about 2.2 to 2.5 KB in the two templates measured, for the first object that ticks the box).
The compiler checks the plain cases. A line of code that gives a ticked object a speed, or changes its x, y, mask or solid after it was set up, is refused with a message that says which object and which line. Setting it up is fine: in its own Create event, in the creation code of a copy you placed in a room, or inside with (instance_create(...)) { ... }.
The compiler cannot see everything: a script handed the instance, a with (all), an inherited event. For those the development build (what Build & Play makes, see Development and Release builds) helps: it checks every copy once a frame and again whenever a question looks at it, and when one has moved, resized or changed solid it stops on a message that names the object, for example "Never moves: an instance of obj_wall moved, changed size or changed 'solid'". A release build does not check, as the promise says; a copy that moved there is simply not found where it now stands.
Two kinds of object cannot make the promise at all, because they move by their nature: an object that is a projectile, and an object that a room sends along a path. The compiler says so, and the editor will not let you tick the box on a projectile.
frame and frame_speed are free to change: animating a picture does not change a box.